<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
</head>
<style>
    	td .layui-form-select {
	     margin-top: -10px;
	     margin-left: -15px;
	     margin-right: -15px;
	 }
</style>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline" style="margin-left: 5%;">
                            <label class="layui-form-label">巡检时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="time_xun"  autocomplete="off" disabled class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline" style="margin-left: 30%;">
                            <label class="layui-form-label">巡检人员</label>
                            <div class="layui-input-inline">
                                <input type="text" name="people" placeholder="巡检人员名称"  autocomplete="off"  class="layui-input">
                            </div>
                        </div>
                    </div>
                </form>
</div>
        <div id="Myloading"><img src="../../lib/layui-v2.5.5/css/modules/layer/default/loading-01.gif" alt=""></div>

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm data-add-btn" lay-event="add"> 更新修改 </button>
            </div>
        </script>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            <a lay-event="edit" ><img src="../../images/icon-qxt.png" alt=""></a>
        </script>

        <script type="text/html" id="remark_temp">
            <input type="text"  lay-vertype="tips" id="k_{{d.LAY_TABLE_INDEX}}" placeholder="{{d.placeholder}}" autocomplete="off" class="layui-input" name="remark" lay-event="editRemark">
            <!-- <input type="text" onkeyup="value=value.replace(/[^\d]/g,'')" lay-vertype="tips" id="k_{{d.LAY_TABLE_INDEX}}" placeholder="{{d.placeholder}}" autocomplete="off" class="layui-input" name="remark" lay-event="editRemark"> -->
        </script>

    </div>
</div>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['form', 'table','miniTab'], function () {
        // 2020-03-25 HF 保存token
        var token = sessionStorage.getItem('newtoken');
        var recordNo = sessionStorage.getItem('HsaveOverHaul_recordNo');
        var x_j = {};
        var device_code = null;

        var $ = layui.jquery,
            form = layui.form,
            miniTab = layui.miniTab,
            table = layui.table;
            miniTab.listen();


 var data = [
			 				   {name:"GIS",
			 				   	   que:"断路器、隔离开关、接地隔离开关、快速接地隔离开关的位置指示器是否正常?",
			 				   	   field:"1",
                                       flag:"positionIndicatorStatus",
                                       placeholder:"填0或1，其中1 = 正常，0 = 异常"
			 				   },
			 				   {name:"GIS",
			 				   	   que:"断路器、隔离开关、接地隔离开关、快速接地隔离开关的闭锁位置是否正常?",
			 				   	   field:"2",
                                        flag:"lockingPositionStatus",
                                        placeholder:"填0或1，其中1 = 正常，0 = 异常"
			 				   },
			 				   {name:"GIS",
			 				   	   que:"各种指示灯、信号灯的指示是否正常?",
			 				   	   field:"3",
                                        flag:"signalLampStatus",
                                        placeholder:"填0或1，其中1 = 正常，0 = 异常"
			 				   },
			 				   {name:"GIS",
			 				   	   que:"隔离开关、接地隔离开关从窥视孔中检查其触头是否正常?",
			 				   	   field:"4",
                                        flag:"switchContactStatus",
                                        placeholder:"填0或1，其中1 = 正常，0 = 异常"
			 				   },
			 				   {name:"GIS",
			 				   	   que:"密度计、压力表的指示值是否正常?",
			 				   	   field:"5",
                                         flag:"meterStatus",
                                         placeholder:"填0或1，其中1 = 正常，0 = 异常"
			 				   },
			 				    {name:"GIS",
			 				   	   que:"二次端子有没有发热现象？",
			 				   	   field:"6",
                                        flag:"secondTerminalStatus",
                                        placeholder:"填0或1，其中1 = 无，0 = 有"
			 				   },
			 				    {name:"GIS",
			 				   	   que:"熔丝、熔断器的指示是否正常？",
			 				   	   field:"7",
                                        flag:"fuseStatus",
                                        placeholder:"填0或1，其中1 = 正常，0 = 异常"
			 				   },
			 				   {name:"GIS",
			 				   	   que:"在GIS设备附近有无异味、异声?",
			 				   	   field:"8",
                                        flag:"soundStatus",
                                        placeholder:"填0或1，其中1 = 正常，0 = 异常"
			 				   },
			 				   {name:"GIS",
			 				   	   que:"设备有没有漏气、漏油现象?",
			 				   	   field:"9",
                                        flag:"leakageOilStatus",
                                        placeholder:"填0或1，其中1 = 正常，0 = 异常"
			 				   },
			 				   {name:"GIS",
			 				   	   que:"所有阀门的开、闭位置是否正常?",
			 				   	   field:"10",
                                        flag:"valveStatus",
                                        placeholder:"填0或1，其中1 = 正常，0 = 异常"
			 				   },
			 				   {name:"GIS",
			 				   	   que:"金属支架有无锈蚀，有无发热现象?",
			 				   	   field:"11",
                                        flag:"metalStentsStatus",
                                        placeholder:"填0或1，其中1 = 无，0 = 有"
			 				   },
			 				   {name:"GIS",
			 				   	   que:"可见的绝缘元件，有没有老化、剥落，有无裂纹的现象?",
			 				   	   field:"12",
                                        flag:"insulatingElementStatus",
                                        placeholder:"填0或1，其中1 = 否，0 = 是"
			 				   },{name:"GIS",
			 				   	   que:"所有金属支架和保护罩，外壳有没有油漆剥落的情况?",
			 				   	   field:"13",
                                        flag:"paintPeelingStatus",
                                        placeholder:"填0或1，其中1 = 否，0 = 是"
			 				   },{name:"GIS",
			 				   	   que:"接地端子有没有发热现象?",
			 				   	   field:"14",
                                        flag:"groundingTerminalStatus",
                                        placeholder:"填0或1，其中1 = 否，0 = 是"
			 				   },{name:"GIS",
			 				   	   que:"金属外壳的温度是否超过规定?",
			 				   	   field:"15",
                                        flag:"metalShellStatus",
                                        placeholder:"填0或1，其中1 = 否，0 = 是"
                                },
                                {name:"GIS",
			 				   	   que:"GMM11",
			 				   	   field:"1",
			 				   	   flag:"agmm11",
			 				   	   placeholder:'0.5~0.6'
			 				   },
			 				   {name:"GIS",
			 				   	   que:"GMM12(CB)",
			 				   	   field:"1",
			 				   	   flag:"agmm12",
			 				   	   placeholder:'0.6~0.7'
			 				  
			 				   },
			 				   {name:"GIS",
			 				   	   que:"GMM13",
			 				   	   field:"1",
			 				   	   flag:"agmm13",
			 				   	   placeholder:'0.5~0.6'
			 				  
			 				   },
			 				   {name:"GIS",
			 				   	   que:"GMM14(CB)",
			 				   	   field:"1",
			 				   	   flag:"agmm14",
			 				   	   placeholder:'0.6~0.7'
			 				  
			 				   },
			 				   {name:"GIS",
			 				   	   que:"GMM15",
			 				   	   field:"1",
			 				   	   flag:"agmm15",
			 				   	   placeholder:'0.5~0.6'
			 				  
			 				   },
			 				   {name:"GIS",
			 				   	   que:"AGMM16(CB)",
			 				   	   field:"1",
			 				   	   flag:"agmm16",
			 				   	   placeholder:'0.6~0.7'
			 				  
			 				   },
			 				   {name:"GIS",
			 				   	   que:"AGMM17",
			 				   	   field:"1",
			 				   	   flag:"agmm17",
			 				   	   placeholder:'0.5~0.6'
			 				  
			 				   },
			 				   {name:"GIS",
			 				   	   que:"AGMM18",
			 				   	   field:"1",
			 				   	   flag:"agmm18",
			 				   	   placeholder:'0.5~0.6'
			 				  
			 				   },
			 				   {name:"GIS",
			 				   	   que:"AGMM19",
			 				   	   field:"1",
			 				   	   flag:"agmm19",
			 				   	   placeholder:'0.5~0.6'
			 				  
			 				   }
	 		        	];

            table.render({
                    elem: '#currentTableId',
                    toolbar: '#toolbarDemo',  
                    data:data,
                    defaultToolbar: ['filter', 'exports', 'print', {
                        title: '提示',
                        layEvent: 'LAYTABLE_TIPS',
                        icon: 'layui-icon-tips'
                    }],
                    
                    cols: [[
                        //复选框 {type: "checkbox", width: 50, fixed: "left"},
                        {type: 'numbers', width: 120, title: '序号', align: "center"},
                        {field: 'name', width: 150, title: '类型', align: "center"},
                        {field: 'que', minWidth: 110, title: '状况', align: "center"},
                        {field: 'remark', title: '数值', width: 300, align: 'center', templet: '#remark_temp' },
                        {title: '操作', width: 200, templet: '#currentTableBar', fixed: "right", align: "center"}
                    ]],
                    limits: [10, 15, 20, 25, 50, 100],
                    limit: 105,
                    page: false,
                    done:function(res){
                        if (res.code == -1) {
                    window.location = '../login-1.html';
                }
                        // 表格渲染完成回调
                        $('#Myloading').remove();
                         $.ajax({     
                                    url: '/oms-web/patrols/GIS/'+recordNo+'/authority?token='+ token,
                                    dataType:"json",  
                                    type:"get", 
                                    contentType:"application/json",
                                   success:function(data){ if (data.code == -1) {
                          window.location = '../login-1.html'
                      }
                                        if(data.code === 0){
                                            if(data.data != null){
                                                $("input[name='time_xun']").val(data.data.patrolDate);
                                                $("input[name='people']").val(data.data.patrolStaff);
                                                $('#k_0').val(data.data.positionIndicatorStatus);
                                                $('#k_1').val(data.data.lockingPositionStatus);
                                                $('#k_2').val(data.data.signalLampStatus);
                                                $('#k_3').val(data.data.switchContactStatus);
                                                $('#k_4').val(data.data.meterStatus);
                                                $('#k_5').val(data.data.secondTerminalStatus);
                                                $('#k_6').val(data.data.fuseStatus);
                                                $('#k_7').val(data.data.soundStatus);
                                                $('#k_8').val(data.data.leakageOilStatus);
                                                $('#k_9').val(data.data.valveStatus);
                                                $('#k_10').val(data.data.metalStentsStatus);
                                                $('#k_11').val(data.data.insulatingElementStatus);
                                                $('#k_12').val(data.data.paintPeelingStatus);
                                                $('#k_13').val(data.data.groundingTerminalStatus);
                                                $('#k_14').val(data.data.metalShellStatus);
                                                $('#k_15').val(data.data.agmm11);
                                                $('#k_16').val(data.data.agmm12);
                                                $('#k_17').val(data.data.agmm13);
                                                $('#k_18').val(data.data.agmm14);
                                                $('#k_19').val(data.data.agmm15);
                                                $('#k_20').val(data.data.agmm16);
                                                $('#k_21').val(data.data.agmm17);
                                                $('#k_22').val(data.data.agmm18);
                                                $('#k_23').val(data.data.agmm19);
                                            }
                                        }else{
                                            layer.msg(data.msg,{icon: 1,time:1000});
                                        }
                                },
                                    error:function () {
                                        layer.msg("数据请求错误！");
                                    }
                        });
                    }
                });  

        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            device_code = sessionStorage.getItem('HsaveOverHaul_code');
            x_j.patrolDate = $("input[name='time_xun']").val(); 
            if($("input[name='people']").val() == ''){
                x_j.patrolStaff = 'operate';
            }else{
                x_j.patrolStaff = $("input[name='people']").val(); 
            }
            x_j.deviceCode = device_code;

            if(  $('#k_0').val() == '' ||  $('#k_0').val() == '0'){x_j.positionIndicatorStatus = "0"}else{x_j.positionIndicatorStatus = "1" }
            if(  $('#k_1').val() == '' ||  $('#k_1').val() == '0'){x_j.lockingPositionStatus = "0"}else{x_j.lockingPositionStatus = "1" }
            if(  $('#k_2').val() == '' ||  $('#k_2').val() == '0'){x_j.signalLampStatus = "0"}else{x_j.signalLampStatus = "1" }
            if(  $('#k_3').val() == '' ||  $('#k_3').val() == '0'){x_j.switchContactStatus = "0"}else{x_j.switchContactStatus = "1" }
            if(  $('#k_4').val() == '' ||  $('#k_4').val() == '0'){x_j.meterStatus = "0"}else{x_j.meterStatus =  '1' }
            if(  $('#k_5').val() == '' ||  $('#k_5').val() == '0'){x_j.secondTerminalStatus = "0"}else{x_j.secondTerminalStatus = "1" }
            if(  $('#k_6').val() == '' ||  $('#k_6').val() == '0'){x_j.fuseStatus = "0"}else{x_j.fuseStatus = "1" }
            if(  $('#k_7').val() == '' ||  $('#k_7').val() == '0'){x_j.soundStatus = "0"}else{x_j.soundStatus = "1" }
            if(  $('#k_8').val() == '' ||  $('#k_8').val() == '0'){x_j.leakageOilStatus = "0"}else{x_j.leakageOilStatus = "1" }
            if(  $('#k_9').val() == '' ||  $('#k_9').val() == '0'){x_j.valveStatus = "0"}else{x_j.valveStatus = "1" }
            if(  $('#k_10').val() == '' ||  $('#k_10').val() == '0'){x_j.metalStentsStatus = "0"}else{x_j.metalStentsStatus = "1" }
            if(  $('#k_11').val() == '' ||  $('#k_11').val() == '0'){x_j.insulatingElementStatus = "0"}else{x_j.insulatingElementStatus = "1" }
            if(  $('#k_12').val() == '' ||  $('#k_12').val() == '0'){x_j.paintPeelingStatus = "0"}else{x_j.paintPeelingStatus = "1" }
            if(  $('#k_13').val() == '' ||  $('#k_13').val() == '0'){x_j.groundingTerminalStatus = "0"}else{x_j.groundingTerminalStatus = "1" }
            if(  $('#k_14').val() == '' ||  $('#k_14').val() == '0'){x_j.metalShellStatus = "0"}else{x_j.metalShellStatus = "1" }
            if(  $('#k_15').val() == '' ||  $('#k_15').val() == '0'){x_j.agmm11 = "0"}else{x_j.agmm11 = $('#k_15').val() }
            if(  $('#k_16').val() == '' ||  $('#k_16').val() == '0'){x_j.agmm12 = "0"}else{x_j.agmm12 = $('#k_16').val() }
            if(  $('#k_17').val() == '' ||  $('#k_17').val() == '0'){x_j.agmm13 = "0"}else{x_j.agmm13 = $('#k_17').val() }
            if(  $('#k_18').val() == '' ||  $('#k_18').val() == '0'){x_j.agmm14 = "0"}else{x_j.agmm14 = $('#k_18').val() }
            if(  $('#k_19').val() == '' ||  $('#k_19').val() == '0'){x_j.agmm15 = "0"}else{x_j.agmm15 = $('#k_19').val() }
            if(  $('#k_20').val() == '' ||  $('#k_20').val() == '0'){x_j.agmm16 = "0"}else{x_j.agmm16 = $('#k_20').val() }
            if(  $('#k_21').val() == '' ||  $('#k_21').val() == '0'){x_j.agmm17 = "0"}else{x_j.agmm17 = $('#k_21').val() }
            if(  $('#k_22').val() == '' ||  $('#k_22').val() == '0'){x_j.agmm18 = "0"}else{x_j.agmm18 = $('#k_22').val() }
            if(  $('#k_23').val() == '' ||  $('#k_23').val() == '0'){x_j.agmm19 = "0"}else{x_j.agmm19 = $('#k_23').val() }
            layer.confirm('确定修改该数据吗？', {
                        btn: ['确定','取消'] //按钮
                        }, function(){
                            GIS_update(x_j);
                        });
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
        });

        // 获取列表data
        table.on('tool(currentTableFilter)', function (obj) {
                   if(obj.event === 'edit'){
                    sessionStorage.setItem('HsaveOverHaul_flag',obj.data.flag);
                    sessionStorage.setItem('HsaveOverHaul_ms',obj.data.que);
                    
                    var index = layer.open({
                    title: '数据折线图',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: ['80%', '80%'],
                    content: './line_x/line_xj.html'
                    // content: ['./line_x/line_xj.html','no'] //滚动条
                    });
             }
        });
        // 新增接口
        function GIS_update(x_j){
                     $.ajax({          
                            url: '/oms-web/patrols/GIS/'+recordNo+'/authority?token='+ token,
                            dataType:"json",  
                            type:"put", 
                            data:JSON.stringify(x_j) ,
                            contentType:"application/json",
                           success:function(data){ if (data.code == -1) {
                          window.location = '../login-1.html'
                      }
                            if(data.code === 0){
                                        layer.msg(data.msg,{icon: 1,time:1500},function(){
                                            parent.layer.close(iframeIndex);
                                            window.parent.location.reload();//修改成功后刷新父界面
                                        })
                            }else{
                                layer.msg(data.msg,{icon: 1,time:1000});
                            }
                        },
                            error:function () {
                                layer.msg("数据请求错误！");
                                    layer.close(index);
                            }
                 });
          }
        var iframeIndex = parent.layer.getFrameIndex(window.name);
    });

</script>


</body>
</html>